package com.shigi.sat.structure;

/**
 * Created by Miroslav Šiagi on 28/01/15.
 */
public class SatLiteral {
    public int weight = 0;
    public int index = 0;
    public boolean isPositive = true;
    public boolean value = false;

    private SatInstance itsSatInstance;

    public SatLiteral(SatInstance itsSatInstance) {
        this.itsSatInstance = itsSatInstance;
    }

    public SatLiteral(SatLiteral literal, SatInstance itsSatInstance) {
        this.weight = literal.weight;
        this.index = literal.index;
        this.isPositive = literal.isPositive;
        this.value = literal.value;
        this.itsSatInstance = itsSatInstance;
    }

    public boolean evaluate() {
        return (this.isPositive ? itsSatInstance.variablesValues[this.index] : !itsSatInstance.variablesValues[this.index]);
    }
}
